 package gov.sat.tax.fwsk.wlrz;
 
 import java.io.PrintStream;
 import java.util.GregorianCalendar;
 
 public class RzCheckKprqLimit
 {
   public static boolean fpCheckKprqLimit(String kprq, String rzsj)
   {
     GregorianCalendar dkpt = null;
     GregorianCalendar dnow = new GregorianCalendar();
     GregorianCalendar d0301 = new GregorianCalendar(2003, 2, 1);
     GregorianCalendar d0901 = new GregorianCalendar(2003, 8, 1);
     
 
     GregorianCalendar d090101 = new GregorianCalendar(2009, 0, 1);
     int kd;
     int km = 0;
     int ky = 0;
     if (kprq.length() == 8)
     {
        ky = Integer.parseInt(kprq.substring(0, 4));
        km = Integer.parseInt(kprq.substring(4, 6));
       kd = Integer.parseInt(kprq.substring(6, 8));
     }
     else
     {
      
       if (kprq.length() == 6)
       {
          ky = Integer.parseInt(kprq.substring(0, 2)) + 2000;
          km = Integer.parseInt(kprq.substring(2, 4));
         kd = Integer.parseInt(kprq.substring(4, 6));
       }
       else
       {
         return false;
       }
     }
     

     dkpt = new GregorianCalendar(ky, km - 1, kd);
     if (rzsj != null)
     {
       int ry = Integer.parseInt(rzsj.substring(0, 4));
       int rm = Integer.parseInt(rzsj.substring(5, 7));
       int rd = Integer.parseInt(rzsj.substring(8, 10));
       dnow = new GregorianCalendar(ry, rm - 1, rd);
     }
     if (dkpt.before(d0301)) {
       return dnow.before(d0901);
     }
     d0901 = dkpt;
     if (ky >= 2010)
     {
       d0901.add(6, 180);
       System.out.println("[info] kp data limit 180 day kp-year: " + ky);
     }
     else
     {
       d0901.add(6, 90);
       System.out.println("[info] kp data limit 90 day kp-year: " + ky);
     }
     return dnow.before(d0901);
   }
				public static void main(String args[]){
					GregorianCalendar t = new GregorianCalendar(2014,0,1);
					 t.add(6, 2);
					System.out.print(t.getTime().toLocaleString());
					GregorianCalendar t2 = new GregorianCalendar(2014,0,3);
					
					System.out.println(t2.before(t));
					
				}
 }